﻿Imports System.Data.OleDb

Public Class PromotionsRequestManagement
    Inherits ConnectionClass

    Public Sub InsertRequest(ByVal userId As Int32, ByVal RequestTypeId As Int32)
        Try

        
        myConnection.Open()
        Dim SqlString As String = "INSERT Into PromotionsRequest (UserId,PromotionTypeId) VALUES(@f1,@f2)"
        Dim newCmd As OleDbCommand = New OleDbCommand(SqlString, myConnection)
        newCmd.CommandType = CommandType.Text
        newCmd.Parameters.AddWithValue("@f1", userId)
        newCmd.Parameters.AddWithValue("@f2", RequestTypeId)
        newCmd.ExecuteNonQuery()
        myConnection.Close()
        Catch ex As Exception

        End Try
    End Sub


    Public Function SelectPromotionByPromotionId(ByVal promotionId As Int32) As OleDbDataReader
        Try

        
        myConnection.Open()
        Dim SqlString As String = "SELECT *  FROM  PromotionsRequest WHERE  (PromotionRequestId = @f1)"
        Dim cmd As OleDbCommand = New OleDbCommand(SqlString, myConnection)
        cmd.CommandType = CommandType.Text
        cmd.Parameters.AddWithValue("@f1", promotionId)
        Dim dr As OleDbDataReader = cmd.ExecuteReader()
        Return dr
        myConnection.Close()
        Catch ex As Exception
            Return Nothing
        End Try
    End Function


    Public Sub DeleteRequestByRequestID(ByVal RequestId As Int32)
        Try


            myConnection.Open()
            Dim SqlString As String = "DELETE FROM PromotionsRequest WHERE (PromotionRequestId = @f1)"
            Dim newCmd As OleDbCommand = New OleDbCommand(SqlString, myConnection)
            newCmd.CommandType = CommandType.Text
            newCmd.Parameters.AddWithValue("@f1", RequestId)

            newCmd.ExecuteNonQuery()
            myConnection.Close()
        Catch ex As Exception

        End Try

    End Sub


End Class
